#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Demo.Net.API/Demo.Net.API.csproj", "Demo.Net.API/"]
COPY ["Demo.Net.Service/Demo.Net.Service.csproj", "Demo.Net.Service/"]
COPY ["Demo.Net.Dapper/Demo.Net.Dapper.csproj", "Demo.Net.Dapper/"]
COPY ["Demo.Net.EFCore/Demo.Net.EFCore.csproj", "Demo.Net.EFCore/"]
COPY ["Demo.Net.Kafka/Demo.Net.Kafka.csproj", "Demo.Net.Kafka/"]
COPY ["Demo.Net.MongoDB/Demo.Net.MongoDB.csproj", "Demo.Net.MongoDB/"]
COPY ["Demo.Net.RabbitMQ/Demo.Net.RabbitMQ.csproj", "Demo.Net.RabbitMQ/"]
COPY ["Demo.Net.Redis/Demo.Net.Redis.csproj", "Demo.Net.Redis/"]
COPY ["Demo.Net.SqlSugar/Demo.Net.SqlSugar.csproj", "Demo.Net.SqlSugar/"]
RUN dotnet restore "Demo.Net.API/Demo.Net.API.csproj"
COPY . .
WORKDIR "/src/Demo.Net.API"
RUN dotnet build "Demo.Net.API.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "Demo.Net.API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Demo.Net.API.dll"]